﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

using Com.Framework;
using Com.Library.Cookie;
using Com.Library.DB.Manager;
using Com.Library.DB.PageAuth;

namespace Com.Web.coffinegurunaru.manager.usercard
{
	public partial class menu : System.Web.UI.UserControl
	{
		public List<PageAuthSubEntity> PageAuthSubList { get; set; }
		public List<PageSubTypeEntity> SubPageList { get; set; }
		public ManagerCookie m_cookie = null;
		public byte IsManager = 0;

		public int SubPageType { get; set; }

		protected void Page_Load(object sender, EventArgs e)
		{
			m_cookie = new ManagerCookie();

			PageAuthSubList = PageAuthModel.PageAuthSubList(m_cookie.ManagerSN, 3);
			SubPageList = PageAuthModel.SubPageList(3);
			IsManager = ManagerModel.GetInfo(m_cookie.ManagerSN, m_cookie.ManagerID).IsManager;
		}

		public bool IsCheck(int SubPageType)
		{
			if (IsManager == 1)
				return true;

			foreach (var item in PageAuthSubList)
			{
				if (item.SubPageType == SubPageType)
				{
					return item.CodeAuthType == 1 ? true : false;
				}
			}

			return false;
		}
	}
}